package com.cloudsubassemblykafka10024.boot.service.impl;

import com.cloudsubassemblykafka10024.boot.service.IMessageSenderService;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2024/12/26 19:10
 * @Version 1.0
 */
@Service
@Transactional
public class ImessageSenderServiceImpl implements IMessageSenderService {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    @Override
    public void sendMessage(String topic, String key, String message) {
        kafkaTemplate.send(new ProducerRecord<>(topic, key, message));
    }
}
